﻿using Red.Controls.Shell;
using Red.Toolkit.MeshEditor.ViewModels;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Documents;

namespace Red.Toolkit.MeshEditor.Controls
{
    /// <summary>
    /// Interaction logic for addLodDialog.xaml
    /// </summary>
    public partial class AddLodDialog : RedDialog
    {
        #region Properties

        public LodDescriptionViewModel LodDesc { get; set; }
        public bool DataMode { get; set; }

        #endregion

        #region C-tor

        public AddLodDialog( FrameworkElement ownerSource, LodDescriptionViewModel lodDesc = null )
            : base( ownerSource )
        {
            LodDesc = lodDesc ?? new LodDescriptionViewModel();
            DataContext = this;

            DataMode = false;
            Type = RedDialogType.OkCancel;
            InitializeComponent();
        }

        #endregion

        #region Public methods

        public bool Execute_ActionMode( int lodsNum )
        {
            List<string> availableLods = new List<string>();
            for ( int i = 0; i <= lodsNum; ++i )
            {
                availableLods.Add( i.ToString() );
            }
            _lodNumberCBox.ItemsSource = availableLods;

            if ( LodDesc.SelectedLod == -1 )
            {
                LodDesc.SelectedLod = lodsNum;
            }

            return Show();
        }

        public bool Execute_DataMode()
        {
            DataMode = true;
            return Show();
        }

        #endregion

        #region Event handlers

        private void OkButton_Click( object sender, RoutedEventArgs e )
        {
            DialogResult = true;
        }

        #endregion
    }
}
